import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(primarySwatch: Colors.blue, useMaterial3: false),
      home: Scaffold(
        appBar: AppBar(title: Text("app")),
        body: MyHomePage(),
      ),
    );
  }
}

//使用SliverGridDelegateWithFixedCrossAxisCount
class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      height: double.infinity,
      color: Colors.black,
      child: Row(
        //外部没有container行是自适应的
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        crossAxisAlignment: CrossAxisAlignment.end,
        children: [
          IconContainer(icon: Icons.home),
          IconContainer(icon: Icons.home, color: Colors.purple),
          IconContainer(icon: Icons.home, color: Colors.red),
        ],
      ),
    );
  }
}

class IconContainer extends StatelessWidget {
  final Color color;
  final IconData icon;
  const IconContainer({
    super.key,
    required this.icon,
    this.color = Colors.yellow,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      alignment: Alignment.center,
      height: 120,
      width: 120,
      color: color,
      child: Icon(icon, color: Colors.white, size: 28),
    );
  }
}
